package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderMapper {
    /*
    * 插入订单数据*/
    void insert(Orders orders);

    /*
    * 分页条件查询并按照下单时间排序*/
    Page<Orders> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where id = #{id}")
    Orders getById(Long id);

    /*
    * 根据状态统计订单数量*/
    @Select("select count(id) from orders where status = #{confirmed}")
    Integer countStatus(Integer confirmed);

    @Update("update orders set status = #{orders.status} where id = #{orders.id}")
    void update(Orders orders);
}
